package com.example.boot2mybatis.service.impl;

import com.example.boot2mybatis.mapper.UserMapper;
import com.example.boot2mybatis.service.UserService;
import com.example.boot2mybatis.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.security.SecureRandom;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    public String login(String name, String password) {
        User u =userMapper.login(name);
        System.out.println(u);
        if(null!=u && password.equals(u.getPassword())){

            System.out.println("用户："+name+"密码："+password);
            System.out.println("login success!");
            return "login success!";
        }else{
            System.out.println("输入用户："+name+"输入密码："+password);
            System.out.println("login fail! ");
            return "login fail! ";
        }

    }


    @Override
    public String loginAn(String name, String password) {
        User u =userMapper.loginAn(name);
        System.out.println("---loginAn---"+u);
        if(null!=u && password.equals(u.getPassword())){

            System.out.println("用户："+name+"密码："+password);
            System.out.println("loginAn success!");
            return "loginAn success!";
        }else{
            System.out.println("输入用户："+name+"输入密码："+password);
            System.out.println("loginAn fail! ");
            return "loginAn fail! ";
        }
    }

    public void bigInsert(){

    }


}
